// 问卷提交列表
const conn = require("./conn.js")
module.exports = (req, res) => {
    setTimeout(() => {
        // 每次请求的时候都会发送cookie，cookie中有id
        let paper_id =req.cookies.paper_id
        // 要调取title，需要调取两个数据库表，，也可以用搜索语句对两个表进行查询（即双表查询）
        var sql = 'select answer.id id,answer.title title,answer.paper_id paper_id,answer.content content,answer.item item,answer.ctime ctime from answer,papers where answer.paper_id=papers.id && answer.paper_id="'+paper_id+'"'
        conn.query(sql, function (error, result) {
            if (error == null) {
                res.json({
                    error: 0,
                    message: 'ok',
                    data:result
                })
            } else {
                console.log(error)
                res.json({
                    error: 1,
                    message: 'error'
                })
            }
        })
    }, 500)

}